import React from 'react';
import '../style.css';
import { Link } from 'react-router-dom';



class ListItems extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            item: {},
            index: 0
        }
    }


    render() {
        return (
            <Link to='/details'>
                <div className="list_item_container" onClick={()=>{
                    this.props.history.push({pathname:'/details',query:{data:this.state.item}})
                }}>
                    <img src={this.state.item.productImage} alt="" />
                    <div>{this.state.item.productName}</div>
                    <div className="item_title">￥{this.state.item.salePrice}.00元</div>
                </div>
            </Link>
        )
    }

    componentDidMount() {
        this.setState({
            item: this.props.item,
            index: this.props.index
        })
    }
}

export default ListItems